package com.example.studentmanagement.service.impl;

import com.example.studentmanagement.entity.StudentCourse;
import com.example.studentmanagement.mapper.StudentCourseMapper;
import com.example.studentmanagement.service.StudentCourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 〈功能概述〉<br>
 *
 * @className: StudentCourseServiceImpl
 * @author: 程序员Mars
 * @date: 2024/12/25 23:46
 */
@Service
public class StudentCourseServiceImpl implements StudentCourseService {
    @Autowired
    private StudentCourseMapper studentCourseMapper;

    @Override
    public List<StudentCourse> getCoursesByStudentId(Integer studentId) {
        return studentCourseMapper.findByStudentId(studentId);
    }

    @Override
    public List<StudentCourse> getStudentsByCourseId(Integer courseId) {
        return studentCourseMapper.findByCourseId(courseId);
    }

    @Override
    public void createStudentCourse(StudentCourse studentCourse) {
        studentCourseMapper.insert(studentCourse);
    }

    @Override
    public void deleteStudentCourse(Integer id) {
        studentCourseMapper.deleteById(id);
    }
}